<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2017 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 李邦琦 <1536549251@qq.com>
// +----------------------------------------------------------------------

namespace app\crm\controller;
use think\Db;
use think\Controller;

class CrmController extends Controller
{
    /**
     * 排除不需要登录验证的 他妈的不怎么管用啊 所以在有不需要的方法的控制器开头再写一下 only
     * @var [array]
     */
    protected $beforeActionList = [
        'checkLogin' => ['except'=>'checkLogin,login,userLogin'],
    ];


    /**
     * 生成18位ID
     * @return [str] [ID]
     */
    protected function generateID()
    {
        $id = date('mdHis').mt_rand(100000, 999999);
        // 返回ID
        return $id;
    }


    /**
     * 验证登录
     * @return [array] [验证登录]
     */
    public function checkLogin ()
    {
        // echo 333;exit;
        // 先判断有没有SESSION
        if (!isset($_SESSION["user_info"])) {
            echo '<script>top.location.replace("/index.php/crm/Index/login");</script>';
            exit;
        }
        // 判断当前是否是本次登录
        if (md5($_SESSION['user_info']['login_mark'].$_COOKIE['password']) != $_COOKIE['login_mark']) {
            echo '<script>top.location.replace("/index.php/crm/Index/login");</script>';
            exit;
        }

        
    }


}